studentMessage = function(){	
	
	var historyList = Ext.create('Ext.Panel',{
		id:'history_panel',
		title:'历史记录',
		autoScroll : true,
		height:400,
		width:450
		
	});
	
	function historyMsg(options, success, response){
		var data = Ext.JSON.decode(response.responseText.trim());
	//	Ext.getCmp("history_panel").body.update("sadrhgsdfhsdf");
		//moveScroll();	
	}
	var messageList = Ext.create('Ext.Panel',{
		id:'messageList_panel',
		title:'消息记录',
		autoScroll : true,
		height:290,
		width:450
	});
	var messageInput = Ext.create('Ext.Panel',{
		height:100,
		width:450,
		buttonAlign:'right',
		items:[{
			id:'messageText',
			xtype:'xhtmleditor',
			height:80,
			width:450,
			maxLength:70
		}],
		buttons:[ {
			xtype : "button",
			id:'submitBtn',
			text : "发送",
			handler: function(){
				if(Ext.getCmp('messageText').isValid()){
					messageSend();
				}
            	  
            }
		}]
	});
	Ext.Ajax.request( {
		url : "showNewMessageStrAction.action",	
		success : function(response, option) {
			var obj = Ext.decode(response.responseText);
			Ext.getCmp("messageList_panel").body.update(obj.msg);
			var d = Ext.getCmp('messageList_panel').body.dom;
			d.scrollTop = d.scrollHeight - d.offsetHeight;
			document.getElementById("d2").innerHTML = "暂无消息";
		},
		failure : function(response, option) {
			
		}
    	});
	
	Ext.Ajax.request( {
    	url : "qryBystudentIdStudentMessageAction.action", 
    	params : {
    		studentid:STUDENT_ID
    	}, //参数
    	success : function(response, option) {
    		var obj = Ext.decode(response.responseText);
    		Ext.getCmp("history_panel").body.update(obj.msg);
    		
    	},
    	failure : function(response, option) {
    		Ext.Msg.alert("失败", "系统错误");
    	}
    	});
	function messageSend(){
	/*	var selectedKeys = messageWest.getSelectionModel().getSelection();
		var studentId=selectedKeys[0].get("studentId");*/
	//	var teacherId = 
		var text = Ext.getCmp('messageText').getValue();
		if(text == ''){
			Ext.Msg.alert("提示", "发送内容不能为空！");
			return ;
		}

		var conn = new Ext.data.Connection();
		conn.request({  
            // 请求地址  
            url: 'insertStudentMessageAction.action',  
            method: 'post',  
            params: {teacherId:TEACHER_ID,
            	studentId:STUDENT_ID,
            		text:text
            }, 
            success:function(response, option){
            	var submitTime = Ext.Date.format(new Date(), 'Y-m-d g:i:s');
        		var chat_record = new Ext.Element(document.createElement('div'));
        		//var msg = '<div style="margin:10px 5px 10px 5px;text-align:right;"><img src="Image/im32x32.gif" width="20px"/>'+submitTime+'<div style="background:#FEEC98;border-radius: 5px;padding: 10px 10px;margin-right:5px;width: auto;">'+text+'</div> </div>';
        		  var msg = '<div style="margin:10px 5px 10px 5px;text-align:right;"><img src="Image/im32x32.gif" width="20px"/><span style="color:red">[我] </span>'+submitTime+'<br><div style="background:#CDD7E2;width:auto;border-radius: 5px;padding: 10px  10px;"> '+text+'</div></div>';
        		chat_record.update(msg);  
        		Ext.getCmp("messageList_panel").body.appendChild(chat_record);
        		Ext.getCmp('messageText').reset();
        	//	moveScroll();
            },
            failure : function(response, option) {
        		Ext.Msg.alert("发送失败", "系统错误");
        	},
            // 指定回调函数  
           callback: historyMsg  
        });
	};
	function moveScroll(){
		var d = Ext.getCmp('history_panel').body.dom;
		d.scrollTop = d.scrollHeight - d.offsetHeight;		
	}
	var messageCenter = Ext.create('Ext.Panel',{
		height:400,
		width:460,
		 frame: true,
		 
		   // html: "<div class='footer'></div>",
		// region: 'center',
		 //collapsible: true,
		 
		 items:[messageList,messageInput]
		      
	});
	
	
	var messagePanel = Ext.create('Ext.panel.Panel',{
		enableTabScroll: true,
		width:'100%',
		height:400,
		//x:100,
		//layout: 'column',
       // layout: 'border',
		//margin:'2 10 3 10',
		//title:"kkkkkk",
		region:'center',
		layout: {
		    type: 'hbox',
		    align: 'middle ',
		    pack: 'center'
		},
		/*layout:{    
			align: 'center',
            type:'table',//表格布局    
            columns:2 //设置表格布局默认列数为2列    
        },*/ 
       items: [historyList,messageCenter],
        listeners: {
            'afterrender': function () {
         	  // Ext.Msg.alert("ss",store.first().get('studentId'));           	
            }
        }
	});
	if(TEACHER_ID=="" || TEACHER_ID==null){
		
		Ext.Msg.alert("提示",'你暂时还没有分配导师，不能发送消息！');        
	}
	/*var map = new Ext.KeyMap(messagePanel.getEl(), {
		key : 13, //回车的键盘key值
		fn : function(){alert("dfd");}
//确定事件    
});*/
	return messagePanel;
};
